fix: revert np.where to xarray.where when adding vars/ constraints#575
fix: revert np.where to xarray.where when adding vars/ constraints#575FabianHofmann merged 3 commits intoPyPSA:masterfrom
Conversation
|
@lkstrp Sorry if this causes troubles. |
no this is rather on me, I though we had the internal constraint already that masks have to have the same shape as constraints/variables |
FabianHofmann
left a comment
There was a problem hiding this comment.
thanks for spotting this so quickly @lkstrp
We could also make this explicit with a test and error message, and break things for a couple of people. Or revert and break with next minor release
No worries, those things can slip through. It just gets more likely with the vast amount of code produced these days, and we need to watch out |
|
Yes, PR's are getting easier those days, as you can see from mine i guess... |
|
sorry, for the gibberish in the last comment, I was in a meeting. I would say let's revert this, in particular given the failing pypsa functions. then updating linopy to the latest and keeping pypsa v1.0.x does not break. But I would like to require |
#555 introduced masking and used
np.whereinstead ofxarray.wheresince is is "38x faster than xarray where".But
xarrayis slower for a reason, since it aligns operands by dimension name, not just position.np.whererequires shapes to match positionally, which is not guaranteed inadd_variablesoradd_constraints. This PR just reverts the changes, we should add tests and release a patch tomorrow.See https://github.com/PyPSA/linopy/pull/555/changes#diff-1a9bf239769f2af33c90e00a21f7f08e2f40d626ce06ee470bb2daa65ac06a04R788-R789